﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.ZNH.ZMCommon.Prompt;
using Baosight.Platform.Core;

namespace Baosight.ZNH.ZMCF.UI.ChildWindows
{
    public partial class ContactDepartment : EFViewCmes
    {

        public ContactDepartment()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommitClick(object sender, RoutedEventArgs e)
        {
            TempButton = sender as Button;
            TempButton.IsEnabled = false;

            EIInfo info = new EIInfo();
            info.Set(EIConstants.ServiceNameKey, "ZMCF27");
            info.Set(EIConstants.MethodNameKey, "insert");
            EIBlock block = info.AddBlock(EIConstants.ResultBlock);
            EIColumn column = new EIColumn();
            column.SetName("fdKeyId");
            block.AddColumn(column);

            column = new EIColumn();
            column.SetName("fdContactlistId");
            block.AddColumn(column);

            column = new EIColumn();
            column.SetName("fdReceiveId");
            block.AddColumn(column);

            foreach (EIRow tmp in this.grid.CheckedEIRows)
            {
                EIRow row = new EIRow();
                row.Add("fdKeyId", "");
                row.Add("fdContactlistId", this.fdContactlistId.Value);
                row.Add("fdReceiveId", tmp["orgCode"]);
                block.AddRow(row);
            }
            this.Submit(info, base.DoCommitCompleted);
        }

        /// <summary>
        /// 取消按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            CmesWindows _window = this.Parent as CmesWindows;
            _window.DialogResult = false;
            _window.Close();
        }
    }
}

